﻿Imports DTO
Imports System.Data.OleDb
Public Class CThamSoDAO

    Public Function CapNhatThamSo(ByVal _TSdto As CThamSoDTO) As Integer
        Dim cnn As OleDbConnection = CDaTaProviderDAO.ConnectDB()
        cnn.Open()
        Dim _strcapnhat = "update THAMSO set TuoiToiThieu=" + _TSdto.TuoiToiThieu.ToString() + ",TuoiToiDa=" + _TSdto.TuoiToiDa.ToString() + ",QuiDinhDat=" + _TSdto.QuiDinhDat.ToString() + ""
        Dim _cmd As New OleDbCommand(_strcapnhat, cnn)
        Dim _kt As Integer = _cmd.ExecuteNonQuery()
        cnn.Close()
        Return _kt
    End Function

    Public Function LayDuLieuThamSo() As List(Of CThamSoDTO)
        Dim cnn As OleDbConnection = CDaTaProviderDAO.ConnectDB()
        cnn.Open()
        Dim _str = "select TuoiToiThieu,TuoiToiDa,QuiDinhDat from THAMSO"
        Dim _cmd As New OleDbCommand(_str, cnn)
        Dim _reader As OleDbDataReader = _cmd.ExecuteReader()
        Dim _ds As New List(Of CThamSoDTO)
        While _reader.Read()
            Dim _TSdto As New CThamSoDTO()
            _TSdto.TuoiToiThieu = _reader.GetInt32(0)
            _TSdto.TuoiToiDa = _reader.GetInt32(1)
            _TSdto.QuiDinhDat = _reader.GetInt32(2)
            _ds.Add(_TSdto)
        End While

        cnn.Close()
        Return _ds
    End Function
End Class
